package com.meilai.project.controller.web.market.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilai.project.controller.web.market.entity.BillMarketDetail;
import com.meilai.project.controller.web.market.mapper.BillMarketDetailMapper;
import com.meilai.project.controller.web.market.service.BillMarketDetailService;
import com.meilai.project.controller.web.market.vo.BillMarketDetailVO;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BillMarketDetailServiceImpl extends ServiceImpl<BillMarketDetailMapper, BillMarketDetail> implements BillMarketDetailService {
    @Override
    public void deleteByMarketId(Long marketId) {
        LambdaQueryWrapper<BillMarketDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BillMarketDetail::getBill_market_id, marketId);
        remove(wrapper);
    }

    @Override
    public BillMarketDetail queryByMarketDetailId(Long marketDetailId) {
        return baseMapper.selectById(marketDetailId);
    }

    @Override
    public List<BillMarketDetailVO> listByMarketId(Long marketId) {
        return baseMapper.selectListByMarketId(marketId);
    }

    @Override
    public Long insert(BillMarketDetail billMarketDetail) {
        return save(billMarketDetail) ? billMarketDetail.getId() : 0L;
    }
}
